﻿/*****************************************************************//**
 * @file    FITKAcousticsVTKGraphObjectSEAJunctionPoint.h
 * @brief   Graph object for SEA junction point data.
 *  
 * @author  ChengHaotian (yeguangbaozi@foxmail.com)
 * @date    2024-11-13
 *********************************************************************/

#ifndef __FITKACOUSTICSVTKGRAPHOBJECTSEAJUNCTIONPOINT_H__
#define __FITKACOUSTICSVTKGRAPHOBJECTSEAJUNCTIONPOINT_H__

#include "FITKAcousticsVTKGraphObjectJunctionBase.h"

#include "FITKAcousticsVTKGraphAdaptorAPI.h"

// Forward declaration
class vtkUnstructuredGrid;
class vtkPoints;
class vtkGlyph3D;
class vtkSphereSource;

class FITKAcousticsVTKGraphActor;

namespace Acoustics
{
    class FITKSEAJunctionPoint;
    class FITKAcousticsSEANodeList;
}

namespace Exchange
{
    class FITKAcousticsVTKGraphObjectSelect;
}

namespace Exchange
{
    /**
     * @brief   Graph object for 'SEA junction point'.
     * @author  ChengHaotian (yeguangbaozi@foxmail.com)
     * @date    2024-11-13
     */
    class FITKACOUSTICSGRAPHADAPTORAPI FITKAcousticsVTKGraphObjectSEAJunctionPoint : public FITKAcousticsVTKGraphObjectJunctionBase
    {
        // Regist
        FITKGraphObjectRegist(FITKAcousticsVTKGraphObjectSEAJunctionPoint, FITKAcousticsVTKGraphObjectJunctionBase);
        FITKCLASS(Exchange, FITKAcousticsVTKGraphObjectSEAJunctionPoint);

    public:
        /**
         * @brief   Constructor.
         * @param   jPoint: The junction point data
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        FITKAcousticsVTKGraphObjectSEAJunctionPoint(Acoustics::FITKSEAJunctionPoint* jPoint);

        /**
         * @brief   Destructor.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        ~FITKAcousticsVTKGraphObjectSEAJunctionPoint();

        /**
         * @brief   Update the visibility with data object's visibility.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        void updateVisibility() override;

    private:
        /**
         * @brief   Intialize.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        void init() override;

        /**
         * @brief   Generate the vtkDataSet for the junction.[override]
         * @param   junction: The junction data
         * @return  Is the data valid
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        bool generateDataSet(Acoustics::FITKAbstractJunction* junction) override;

        /**
         * @brief   Generate the actor with the junction data.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        void generateGraph() override;

        /**
         * @brief   Update the sphere size by the boundary of all SEA nodes.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        void updateGlyphSizeByRatio() override;

        /**
         * @brief   Clear all vtk data.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        void resetVtkData() override;

    private:
        /**
         * @brief   The size of the glyph source.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        double m_glyphSize = 30.;

        /**
         * @brief   The cube glyph for the nodes.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        vtkGlyph3D* m_glyph{ nullptr };

        /**
         * @brief   The sphere source for the nodes glyph.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        vtkSphereSource* m_sphereSource{ nullptr };

        /**
         * @brief   The grid data for the junction lines.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        vtkUnstructuredGrid* m_ugridLine{ nullptr };

        /**
         * @brief   The points of the junction lines.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        vtkPoints* m_pointsLine{ nullptr };

        /**
         * @brief   The actor for the junction lines.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        FITKAcousticsVTKGraphActor* m_fActorLine{ nullptr };

    };
}   // namespace Exchange

#endif // __FITKACOUSTICSVTKGRAPHOBJECTSEAJUNCTIONPOINT_H__
